﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using StructureMap.Configuration.DSL;
using Universum.Controllers;
using Universum.Infrastructure.Security;
using System.Security.Principal;

namespace Universum.Infrastructure.Configuration
{
	internal class PrincipalInstance : StructureMap.Pipeline.Instance
	{
		protected override object build(Type pluginType, StructureMap.BuildSession session)
		{
			return HttpContext.Current.User;
		}

		protected override string getDescription()
		{
			return "Returns the current _Principal from the HttpContext";
		}
	}
	public class SecurityRegistry : Registry
	{
		public SecurityRegistry()
		{
			ForRequestedType<IAuthentication>().TheDefaultIsConcreteType<FormsAuthenticationService>();
			ForRequestedType<IMembershipService>().TheDefaultIsConcreteType<UserMembershipService>();
			InstanceOf<IPrincipal>().IsThis(new PrincipalInstance());
			
				
		}
	}
}
